home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1987 January / Ahoy_Magazine_87-01_1987_Double_L.d64 / Counting Combo (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  392b  |  16 lines

  1. 0 rem << cd37-8 >>
  2. 1 rem commodares problem #33-4:
  3. 2 print"[147]   counting combinations"
  4. 3 rem solution by
  5. 4 rem    jim speers
  6. 5 rem
  7. 10 input"enter n,r";n,r:if n<r then 10
  8. 20 n$=str$(n) : r$=str$(r)
  9. 30 if n=0 then end
  10. 40 if n=r or r=0 then t=1 : goto 70
  11. 50 if (n-r)<r then r=n-r
  12. 60 t=1 : for i=1 to r : t=t*n/i : n=n-1 : next
  13. 70 print"there are";t;"combinations of"
  14. 80 print n$;" things taken ";r$;" at a time."
  15. 90 print"" : goto 10
  16.